﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HeresyManager.Comunication;

namespace HeresyManager
{
    [Serializable]
    public abstract class HomeWorld : IMinMaxRole
    {
        public abstract String Name { get; }



        private Skill[] skills;
        public HomeWorld()
        {
            skills = new Skill[] { new Skills.Awareness(Skill.SkillLevel.Basic),
                new Skills.Barter(Skill.SkillLevel.Basic), new Skills.Carouse(Skill.SkillLevel.Basic),
                new Skills.Charm(Skill.SkillLevel.Basic), new Skills.Climb(Skill.SkillLevel.Basic),
                new Skills.Command(Skill.SkillLevel.Basic), new Skills.Concealment(Skill.SkillLevel.Basic),
                new Skills.Contortionist(Skill.SkillLevel.Basic), new Skills.Deceive(Skill.SkillLevel.Basic),
                new Skills.Disguise(Skill.SkillLevel.Basic), new Skills.Dodge(Skill.SkillLevel.Basic),
                new Skills.Evaluate(Skill.SkillLevel.Basic), new Skills.Gamble(Skill.SkillLevel.Basic),
                new Skills.Inquiry(Skill.SkillLevel.Basic), new Skills.Intimidate(Skill.SkillLevel.Basic),
                new Skills.Logic(Skill.SkillLevel.Basic), new Skills.Scrutiny(Skill.SkillLevel.Basic),
                new Skills.Search(Skill.SkillLevel.Basic), new Skills.SilentMove(Skill.SkillLevel.Basic),
                new Skills.Swim(Skill.SkillLevel.Basic)};
        }

        public virtual IEnumerator<Comunicator> Acire(Character c)
        {
            foreach (var s in skills)
            {
                c.Skills.Add(new Tuple<Skill, dynamic>(s, this));
            }
            if (false)                 //So this is an empty Enumerator
                yield return null;
        }
        public virtual void DeAcire(Character c)
        {
            foreach (var s in skills)
            {
                c.Skills.Remove(new Tuple<Skill, dynamic>(s, this));
            }
        }

        public abstract IDice WeaponSkillDice { get; }
        public abstract IDice BallisitcSkillDice { get; }
        public abstract IDice StrengthDice { get; }
        public abstract IDice ToughnessDice { get; }
        public abstract IDice AgillityDice { get; }
        public abstract IDice IntelligenceDice { get; }
        public abstract IDice PerceptionDice { get; }
        public abstract IDice WillpowerDice { get; }
        public abstract IDice FellowshipDice { get; }

        public abstract IDice WoundsDice { get; }
        public abstract IDice FateDice { get; }

        public abstract Build[] Builds { get; }
        public abstract Age[] Ages { get; }

        public abstract Color[] SkinColors { get; }
        public abstract Color[] HairColors { get; }
        public abstract Color[] EyeColors { get; }

        public abstract Quirk[] Quirks { get; }

        public abstract String OriginDescription { get; }
        public abstract Origin[] Origins { get; }



        /// <summary>
        /// Defice which careers are availble and in which range of the Dice Role
        /// Type of the Careere, min (inclusiv) value of Dice, max(inclusive) value of Dice
        /// </summary>
        public abstract Tuple<Type, int, int>[] AccirableCareers { get; }

        public override string ToString()
        {
            return Name;
        }

        #region Equality
        public static bool operator !=(HomeWorld first, HomeWorld seccond)
        {

            if (first as Object == null)
                return seccond as object != null;
            return !first.Equals(seccond);
        }
        public static bool operator ==(HomeWorld first, HomeWorld seccond)
        {

            if (first as Object == null)
                return seccond as object == null;
            return first.Equals(seccond);
        }

        // override object.Equals
        public override bool Equals(object obj)
        {
            //       
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237  
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }
            return true;
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            int prime = 31;
            int result = 1;
            result = prime
                    * result
                    + this.GetType().GetHashCode();
            return result;
        }
        #endregion




        public abstract int MinRole { get; }

        public abstract int MaxRole { get; }
    }
}
